package demo2;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.MapBinder;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;

public class SampleModule extends AbstractModule {
    @Override
    protected void configure() {
        //bind(HelloPrinterInterface.class).to(ComplexHelloPrinter.class);
        bind(HelloPrinterInterface.class).annotatedWith(Names.named("simple")).to(SimpleHelloPrinter.class);
        bind(HelloPrinterInterface.class).annotatedWith(Names.named("complex")).to(ComplexHelloPrinter.class);

        Multibinder<HelloPrinterInterface> printerSets = Multibinder.newSetBinder(binder(), HelloPrinterInterface.class);
        printerSets.addBinding().to(SimpleHelloPrinter.class);
        printerSets.addBinding().to(ComplexHelloPrinter.class);

        MapBinder<String, HelloPrinterInterface> printerMaps = MapBinder.newMapBinder(binder(), String.class, HelloPrinterInterface.class);
        printerMaps.addBinding("simple").to(SimpleHelloPrinter.class);
        printerMaps.addBinding("complex").to(ComplexHelloPrinter.class);
    }
}
